//*************************************************************************************
// File:        Exceptions.cs
//*************************************************************************************
// Description: Contains various general exceptions.
//*************************************************************************************
// Classes:     XGDESKException : Exception
//*************************************************************************************
// Enum:        XGDESKExceptionCode
//*************************************************************************************
// Author:      ManOguaR
//*************************************************************************************

using System;

namespace Xeralabs.Core
{
    /// <summary>
    /// Encapsulates data for exception handling in Xeralabs.GDESK.
    /// </summary>
    public abstract class XGDESKException : Exception
    {
        private GlobalExceptionCode _glCode;
        private int _error;

        public GlobalExceptionCode GlobalExceptionCode { get { return _glCode; } }
        public int ErrorCode { get { return _error; } }

        public XGDESKException(GlobalExceptionCode globalExCode, int errorCode)
            : this(globalExCode, errorCode, null, null) { }
        public XGDESKException(GlobalExceptionCode globalExCode, int errorCode, string message)
            : this(globalExCode, errorCode, message, null) { }
        public XGDESKException(GlobalExceptionCode globalExCode, int errorCode, string message, Exception innerException)
            : base(message, innerException)
        {
            _glCode = globalExCode;
            _error = ((int)_glCode * 1000) + errorCode;
        }
    }

    /// <summary>
    /// Enumerates exception codes, to quick reference.
    /// </summary>
    public enum GlobalExceptionCode : int
    {
        ENGINE = 100,
        KERNEL = 300,
        Unknown = 999,
    }
}
 